﻿using System;
using System.Data;
using System.Data.SqlClient;
using HRM.DL;
using HRM.DTO_BOPHAN;
namespace HRM.BL
{
    class BL_BOPHAN
    {
        public BL_BOPHAN()
        {
            dao = new DL_BOPHAN();
            _ds = new DataSet();
            _dt = new DataTable();
        }
        #region "Variable" //--------------------------------------
        private string _error = "";
        private DataTable _dt;
        private DataSet _ds;
        private  DL_BOPHAN dao ;
        #endregion

        #region "Properties" //--------------------------------------
        public DataTable Dt
        {
            get { return _dt; }
            set { _dt = value; }
        }
        public string Error
        {
            get { return _error; }
            set { _error = value; }
        }
        public DataSet Ds
        {
            get { return _ds; }
            set { _ds = value; }
        }
        #endregion

        #region "Methods" //--------------------------------------

        public bool GetDataset(string sqlcmd)
        {
            if (!dao.GetDataset(sqlcmd))
            {
                _error = dao.Error;
                return false;
            }
            {
                _ds = dao.Ds;
                return true;
            }        
        }
        public bool Insert(DTO_BOPHAN dto)
        {
            if (!dao.Insert(dto))
            {
                _error = dao.Error;
                return false;
            }
            return true;
        }
        public bool Update(DTO_BOPHAN dto)
        {
            if (!dao.Update(dto))
            {
                Error = dao.Error;
                return false;
            }
            return true;
        }
        public bool Delete(DTO_BOPHAN dto)
        {
            if (!dao.Delete(dto))
            {
                Error = dao.Error;
                return false;
            }
            return true;
        }
        public bool Delete(string ID)
        {
            if (!dao.Delete(ID))
            {
                Error = dao.Error;
                return false;
            }
            return true;
        }
        #endregion
    }
}
